package com.jh.user.pojo.payment;

import cn.jh.common.core.support.jpa.Jsr310Converters;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.google.common.base.MoreObjects;
import org.springframework.data.jpa.domain.AbstractPersistable;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.time.LocalDateTime;


/**
 * 用户交易分润（同步 PaymentChannel.PaymentOrderStatistic）。
 *
 * @author Fuchun
 * @since 1.0
 */
@Entity
@Table(name = "t_payment_profit")
public class PaymentProfit extends AbstractPersistable<Long> {

    /** PaymentChannel.PaymentOrderStatistic#id */
    @Column(name = "pos_id")
    private Long posId;

    /** 用户id */
    @Column(name = "user_id")
    private Long userId;

    /**
     * ALIPAY - 支付宝
     * WECHAT - 微信支付
     */
    @Column(name = "order_type")
    private String orderType;

    /** 成功交易笔数。*/
    @Column(name = "deal_number")
    private Integer dealNumber;

    /** 交易金额总和 */
    @Column(name = "total_amount")
    private BigDecimal totalAmount;

    /** 总分润金额。*/
    @Column(name = "total_profit")
    private BigDecimal totalProfit;

    /** 统计周计数（自然周）。 */
    @Column(name = "week_of_year")
    private Integer weekOfYear;

    /** 分润状态。*/
    @Column(name = "status")
    @Enumerated(EnumType.ORDINAL)
    private ProfitStatus status;

    /** 记录生成日期。*/
    @Column(name = "create_time")
    @Convert(converter = Jsr310Converters.LocalDateTimeConverter.class)
    private LocalDateTime createTime;

    @Override
    public void setId(Long id) {
        super.setId(id);
    }

    public Long getPosId() {
        return posId;
    }

    public void setPosId(Long posId) {
        this.posId = posId;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getOrderType() {
        return orderType;
    }

    public void setOrderType(String orderType) {
        this.orderType = orderType;
    }

    public Integer getDealNumber() {
        return dealNumber;
    }

    public void setDealNumber(Integer dealNumber) {
        this.dealNumber = dealNumber;
    }

    public BigDecimal getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }

    public BigDecimal getTotalProfit() {
        return totalProfit;
    }

    public void setTotalProfit(BigDecimal totalProfit) {
        this.totalProfit = totalProfit;
    }

    public Integer getWeekOfYear() {
        return weekOfYear;
    }

    public void setWeekOfYear(Integer weekOfYear) {
        this.weekOfYear = weekOfYear;
    }

    public ProfitStatus getStatus() {
        return status;
    }

    public void setStatus(ProfitStatus status) {
        this.status = status;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                .add("id", getId())
                .add("posId", posId)
                .add("userId", userId)
                .add("dealNumber", dealNumber)
                .add("totalAmount", totalAmount)
                .add("totalProfit", totalProfit)
                .add("weekOfYear", weekOfYear)
                .add("status", status)
                .add("createTime", createTime)
                .toString();
    }
}
